package model

import (
	"database/sql/driver"
	"encoding/json"
	"gorm.io/gorm"
	"time"
)

type GormStringList []string

func (g *GormStringList) Scan(value interface{}) error {
	return json.Unmarshal(value.([]byte), &g)
}

func (g GormStringList) Value() (driver.Value, error) {
	return json.Marshal(g)
}

type BaseModel struct {
	ID        int32          `json:"id" gorm:"primarykey;type:int(11)"`
	CreatedAt time.Time      `json:"created_at" gorm:"column:created_at"`
	UpdatedAt time.Time      `json:"-" gorm:"column:update_time"`
	DeletedAt gorm.DeletedAt `json:"-"`
}
